#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string s1,s2,s21,s22;
	char c1,c2;
	cin>>s1>>c1>>s2>>c2;
	int n=0;
	for(int i=0;i<s1.size();i++)
		if(s1[i]==c1){
			s21.push_back(c1);
			n++;
		}
	if(n==0) s21.push_back('0');
	n=0;	
	for(int i=0;i<s2.size();i++)
		if(s2[i]==c2){
			s22.push_back(c2);
			n++;
		}
	if(n==0) s22.push_back('0');		
	int num1=stoi(s21);
	int num2=stoi(s22);
	printf("%d",num1+num2);
	return 0;
} 
